package com.ten.shou.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.util.Date;

/**
 * @author ：杨（1964958771@qq.com）
 * @date ：Created in 2022/12/9 16:39
 * @description：
 * @modified By：
 * @version:
 */
@Component
public class MybatisPlusMetaObjectHandler implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
//        this.setFieldValByName("gmt_create", LocalDateTime.now(), metaObject);
        this.setFieldValByName("gmtCreate", LocalDateTime.now(), metaObject);
//        this.strictInsertFill(metaObject, "gmtCreate", LocalDateTime.class, LocalDateTime.now());
        this.strictInsertFill(metaObject, "gmtModified", LocalDateTime.class, LocalDateTime.now());


    }
    @Override
    public void updateFill(MetaObject metaObject) {
        this.setFieldValByName("gmt_modified", LocalDateTime.now(), metaObject);
    }
}

